package top.zuli.package01.class13;

public class ThreadDemo2 extends Thread{
    /*@Override
    public void run() {
        System.out.println("子线程");
    }

    public static void main(String[] args) {
        //1.创建线程对象
        Thread thread = new ThreadDemo2();
        //2.调用线程的run方法,这种方式调用是主线程调用run方法，并没有创建子线程。
        //thread.run();
        //3.调用start()方法,一个线程对象只能调用一个start()方法，否则报异常，因为当前线程的状态
        //已经变为运行状态
        thread.start();
        thread.start();
    }*/

    /*@Override
    public void run() {
        System.out.println("子线程");
    }

    public static void main(String[] args) {
        Thread thread = new ThreadDemo2();
        thread.start();
        thread.start();
    }*/

    @Override
    public void run() {
        System.out.println("子线程");
    }

    public static void main(String[] args) {
        Thread thread = new ThreadDemo2();
        thread.start();
        thread.start();
    }
}